package com.qf.day08.user;

import java.util.Scanner;

public class Menu {
    //声明一个接口printBanner类型的属性
    private PrintBanner printBanner;

    public PrintBanner getPrintBanner() {
        return printBanner;
    }

    public void setPrintBanner(PrintBanner printBanner) {
        this.printBanner = printBanner;
    }

    public void show(){
//        printBanner.print();

        //1.创建局部变量
        UserService userService = new UserServiceImpl();

        while (true){
            System.out.println("请选择功能:1.注册\t2.登录\t3.退出");
            Scanner scanner = new Scanner(System.in);
            String menuItem = scanner.next();
            switch (menuItem){
                case "1":
                    System.out.println("请输入注册的用户名:");
                    String username = scanner.next();
                    System.out.println("请输入注册的密码");
                    String password = scanner.next();
                    boolean flag = userService.regist(username, password);
                    if(flag){
                        System.out.println("成功");
                    }else {
                        System.out.println("失败");
                    }
//                    userService.regist()
                    break;
                case "2":
                    System.out.println("请输入的用户名:");
                    String loginName = scanner.next();
                    System.out.println("请输入的密码");
                    String loginPassword = scanner.next();
                    boolean loginFlag = userService.login(loginName, loginPassword);
                    if(loginFlag){
                        System.out.println("恭喜登录成功");
                    }else {
                        System.out.println("很遗憾登录失败");
                    }
                    break;
                case "3":
                    System.out.println("886");
                    return;
                default:
                    System.out.println("输入错误");
            }
        }
    }
}
